<?php
require_once('Validator.php');
require_once('ValidatorTest.php');
require_once('Strings.php');

$test = new ValidatorTest();
?>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Tester &ndash; Seminarium 2</title>
	</head>
	<body>
	<?php
	/*****************************************
	 * 		AUTOMATISKA ENHETSTESTER
	 *****************************************/
	echo "<h2>Automatiska enhetstester</h2>";
	
	// E-post
	echo "<h3>E-postadress</h3>";
	$test->TestValidateEmail();
	
	// Filtrerad textsträng
	echo "<h3>Filtrerad textsträng</h3>";
	$test->TestFilterString();
	
	// Filtrerad textsträng
	echo "<h3>Nummer</h3>";
	$test->TestValidateNumber();
	
	// Personnummer
	echo "<h3>Personnummer</h3>";
	$test->TestValidateSSN();
	
	// Datum
	echo "<h3>Datum</h3>";
	$test->TestValidateDate();
	
	// Lösenord
	echo "<h3>Lösenord</h3>";
	$test->TestValidatePassword();
	
	
	/*****************************************
	 * 		MANUELLA ENHETSTESTER
	 *****************************************/
	echo "<h2>Manuella enhetstester</h2>";
	
	// Epost
	if(!Validator::ValidateEmail('fa222cm@student.lnu.se'))
		echo "<p>FEL: " . Strings::VALIDATION_EMAIL_INCORRECT . "</p>";
	else
		echo "<p>Test av epost OK.</p>";
	
	// Datum
	if(!Validator::ValidateDate('1984-12-07'))
		echo "<p>FEL 1: " . Strings::VALIDATION_DATE_INCORRECT . "</p>";
	else if(Validator::ValidateDate('2084-12-07') != false)
		echo "<p>FEL 2: " . Strings::VALIDATION_DATE_INCORRECT . "</p>";
	else
		echo "<p>Test för datum OK.</p>";
	
	// Personnummer
	if(Validator::ValidateSSN('2084-12-07') != false)
		echo "<p>FEL 1: " . Strings::VALIDATION_SSN_INCORRECT . "</p>";
	else if(Validator::ValidateSSN('19841207-1212') == false)
		echo "<p>FEL 2: " . Strings::VALIDATION_SSN_INCORRECT . "</p>";
	else
		echo "<p>Test av personnummer OK.</p>";
	
	// Lösenord
	if(!Validator::ValidatePassword('1dv408'))
		echo "<p>FEL: " . Strings::VALIDATION_PASSWORD_INCORRECT . "</p>";
	else
		echo "<p>Test av lösenord OK.</p>";
	?>
	</body>
</html>